home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5a / Make.orig < prev    next >
Encoding:
Text File  |  1993-09-03  |  4.6 KB  |  182 lines

  1. #!/bin/sh
  2.  
  3. # Set some variables which would be difficult to do within a makefile, e.g.
  4. # the date
  5.  
  6. PATH=/bin
  7.  
  8. RXDAY=`date +%d`
  9. RXMONTH=`date +%m`
  10. RXYEAR=`date +%y`
  11.  
  12. RXDAY=`expr $RXDAY + 0`
  13. RXMONTH=`expr $RXMONTH + 0`
  14. RXYEAR=`expr $RXYEAR + 0`
  15.  
  16. GNUDIR=`echo /usr/local/lib/gnu/gcc/sun?/2.*`  # Yuck...
  17.  
  18. CCFLAG=""
  19. LDFLAG=""
  20. DEBUG=""
  21.  
  22. if [ ! -d ${BINDIR:=${HOME}/`/bin/arch`} ]; then BINDIR=`pwd`; fi
  23.  
  24. echo ${REXXIMC:=$BINDIR} >/dev/null # default directory to find rxque/rxmathfn
  25.  
  26. # The first parameter may be a single letter, indicating the type of
  27. # compilation required: n (no flags) g (debug) d (really debug)
  28. # a or p (profile) o (optimise). The default is optimise.
  29. # By default, all compilations except -a are done by gcc.
  30.  
  31. CC=/usr/local/bin/gcc # change to cc if desired
  32. LDL=-ldl
  33.  
  34. case ${1:-nothing} in
  35.    g) CCFLAG=-g;shift;;
  36.    a) CCFLAG=-a;CC=cc;shift;;
  37.    p) CCFLAG="-p -DNO_LDL";LDL="";shift;;
  38.   pg) CCFLAG="-pg -DNO_LDL";LDL="";shift;;
  39.    d) CCFLAG="-g -DDEBUG";
  40.       DEBUG="/usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o";shift;;
  41.    o) CCFLAG=-O2;LDFLAG="-s -n -Bdynamic";shift;;
  42.    n) ;;
  43.    *) CCFLAG=-O2;LDFLAG="-s -n -Bdynamic";;
  44. esac
  45.  
  46. export PATH CCFLAG LDFLAG DEBUG RXDAY RXMONTH RXYEAR BINDIR REXXIMC CC LDL
  47.  
  48. # Move object files and, if "install", executables, from bin directory
  49. # into current directory.  This does not happen for "clean" or "lint"
  50. # but it does happen for "clobber"
  51.  
  52. savedir=`pwd`
  53. if [ x$1 != xclean -a x$1 != xlint ]; then
  54.    mvfiles="*.o rxmathfn.rxfn"
  55.    if [ x$1 = xinstall ] ; then
  56.       mvfiles="$mvfiles rexx rxque rxstack";
  57.    fi
  58.    (cd $BINDIR;mv $mvfiles $savedir >/dev/null 2>&1);
  59. fi 
  60.  
  61. # The following setup depends on whether cc or /usr/local/bin/gcc was chosen.
  62.  
  63. if [ $CC = cc ] ; then
  64.    LD=cc
  65.    __MAIN=
  66. else
  67.    LD=cc
  68.    __MAIN="-L$GNUDIR -lgcc"
  69. fi
  70.  
  71. export LD __MAIN
  72.  
  73. echo '
  74. #Makefile for REXX/imc
  75. #Following setup is for SunOS 4.1.1
  76. MORECCFLAGS = -DHAS_TTYCOM -DHAS_MALLOPT -DSTUFF_STACK
  77. LIBRARIES = $(LDL)
  78.  
  79. #For AIX 3.2 using gcc, the following would be appropriate:
  80. #MORECCFLAGS = -DNO_LDL -fsigned-char
  81. #LIBRARIES = -lbsd
  82.  
  83. #For AIX 3.2 using cc, the following would be appropriate:
  84. #CCFLAG=
  85. #LDFLAG=-s
  86. #MORECCFLAGS = -DNO_LDL -qchars=signed
  87. #LIBRARIES = -lbsd
  88.  
  89. #- insert -DNO_CNT in MORECCFLAGS if the FILE structure defined in <stdio.h>
  90. #  does not contain a _cnt element
  91. #- insert -DSTUFF_STACK if you want surplus stacked data to be stuffed into
  92. #  the keyboard buffer before the stack is terminated.  The <sys/termios.h>
  93. #  file should define a TIOCSTI ioctl call.
  94.  
  95. MATH = rxmathfn.rxfn
  96.  
  97. #For any system on which you defined -DNO_LDL above, please insert:
  98. #MATH =
  99.  
  100.  
  101. DATE = -DDAY=$(RXDAY) -DMONTH=$(RXMONTH) -DYEAR=$(RXYEAR)
  102.  
  103. REXX = rexx rxque rxstack
  104. RXCFILES = rexx.c util.c calc.c rxfn.c shell.c globals.c rxmathfn.c
  105. CFILES = $(RXCFILES) rxque.c rxstack.c
  106. OFILES = rexx.o rxfn.o calc.o util.o shell.o globals.o
  107. HFILES = const.h globals.h functions.h
  108. JUNKFILES = rexx rxque rxstack *.o *.c\^ *.c% make\^ make% *.h\^ *.h% \
  109.             rexx.ref\^ rexx.summary\^ rexx.info\^ rexx.tech\^ rxmathfn.rxfn
  110. FILEDEFS = -DREXXIMC=\"$(REXXIMC)\"
  111.  
  112. all: $(REXX)
  113.  
  114. # Installation is done by the shell, so make as "all"
  115. install: all
  116.  
  117. rexx: $(OFILES) $(MATH)
  118.     $(LD) $(CCFLAG) $(LDFLAG) $(DEBUG) -o rexx $(OFILES) $(LIBRARIES) \
  119.     $(__MAIN)
  120.  
  121. rxque: rxque.c
  122.     $(CC) $(CCFLAG) $(MORECCFLAGS) -c rxque.c
  123.     $(LD) $(CCFLAG) $(LDFLAG) -o rxque rxque.o $(LIBRARIES) $(__MAIN)
  124.     @rm rxque.o
  125.     
  126. rxstack: rxstack.c
  127.     $(CC) $(CCFLAG) $(MORECCFLAGS) -c rxstack.c
  128.     $(LD) $(CCFLAG) $(LDFLAG) -o rxstack rxstack.o $(LIBRARIES) $(__MAIN)
  129.     @rm rxstack.o
  130.  
  131. # compile individual object files:
  132.  
  133. rex: rexx.o
  134.  
  135. rxfn: rxfn.o
  136.  
  137. calc: calc.o
  138.  
  139. util: util.o
  140.  
  141. shell: shell.o
  142.  
  143. math: rxmathfn.rxfn
  144.  
  145. # clobber erases the object files from the bin directory too. They have
  146. # already been moved here by the shell, so just do "clean"
  147. clobber: clean
  148.  
  149. clean:
  150.     rm -f $(JUNKFILES)
  151.  
  152. lint: $(HFILES) $(CFILES)
  153.     @echo lint $(RXCFILES)
  154.     @(lint $(DATE) $(FILEDEFS) $(RXCFILES);\
  155.     echo rxque.c:;\
  156.     echo lint rxque.c >&2;\
  157.     lint rxque.c;\
  158.     echo rxstack.c:;\
  159.     echo lint rxstack.c >&2;\
  160.     lint rxstack.c) | ./lintfilter
  161.     @echo "Messages are in /tmp/lint"
  162.  
  163. rexx.o: rexx.c $(HFILES)
  164.     $(CC) -c $(CCFLAG) $(MORECCFLAGS) $(DATE) $(FILEDEFS) rexx.c
  165.  
  166. rxmathfn.rxfn: rxmathfn.c const.h functions.h
  167.     $(CC) -c $(CCFLAG) $(MORECCFLAGS) rxmathfn.c
  168.     ld -o rxmathfn.rxfn rxmathfn.o -lm
  169.     @rm rxmathfn.o
  170.     
  171. .c.o: $(HFILES)
  172.     $(CC) -c $(CCFLAG) $(MORECCFLAGS) $*.c
  173. '|make -f - $*
  174.  
  175. # Move the object files, and, if "install", the executables,
  176. # into the bin directory. Do not do this after "clobber", of course.
  177.  
  178. if [ "x$mvfiles" != x -a x$1 != xclobber ] ; then
  179.    echo mv $mvfiles $BINDIR
  180.    mv $mvfiles $BINDIR 2>/dev/null;
  181. fi
  182.